package cn.coisini.mapper;

import cn.coisini.model.pojo.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author xiangshaw
 * Description: 文章 数据持久层
 */
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    /**
     * 根据用户ID获取用户已经发布的文章总数
     *
     * @param userId 用户ID
     * @param state 文章状态
     * @return 文章总数
     */
    @Select("SELECT COUNT(*) FROM tb_article WHERE create_user = #{userId} AND state = #{state}")
    Long getArticleCountByUserId(@Param("userId") String userId, @Param("state") short state);
}
